import axios from 'axios'
import { ERR_OK } from './config'

const urlMap = {
  development: 'http://192.168.50.250:3000/',
  production: 'http://192.168.50.250:8888'
}
const baseUrl = urlMap[process.env.NODE_ENV]

export function get(url, params = {}) {
  return new Promise((resolve, reject) => {
    axios.get(baseUrl + url, {
      params: params
    })
      .then(res => {
        if (res.code === ERR_OK) {
          resolve(res)
        }
      })
      .catch(err => {
        reject(err)
      })
  })
}
